package com.ruoyi.notice.service.impl;

import com.ruoyi.notice.domain.Content;
import com.ruoyi.notice.mapper.ContentMapper;
import com.ruoyi.notice.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;

import java.util.List;
import java.util.Optional;

public class ContentServiceImpl implements ContentService {
    @Autowired
    private ContentMapper contentMapper;
    @Override
    public void insert(Content Content) {
        contentMapper.insert(Content);
    }

    @Override
    public void delete(Long id) {
        contentMapper.deleteById(id);
    }

    @Override
    public void update(Content Content) {
        delete(Content.getId());
        insert(Content);
    }

    @Override
    public List<Content> selectAll() {
        return contentMapper.findAll();
    }

    @Override
    public Content getById(Long id) {
        Optional<Content> byId = contentMapper.findById(id);
        return byId.orElse(new Content());
    }
}
